/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.address.URI;
import javax.sip.header.AlertInfoHeader;

/**
 * When present in an INVITE request, the Alert-Info header field
 * specifies an alternative ring tone to the UAS.  When present in a 180
 * (Ringing) response, the Alert-Info header field specifies an
 * alternative ringback tone to the UAC.  A typical usage is for a proxy
 * to insert this header field to provide a distinctive ring feature.
 * <p/>
 * The Alert-Info header field can introduce security risks, which are
 * identical to the Call-Info header field risk, see section 20.9 of
 * <a href = "http://www.ietf.org/rfc/rfc3261.txt">RFC3261</a>.
 * In addition, a user SHOULD be able to disable this feature selectively.
 * This helps prevent disruptions that could result from the use of this
 * header field by untrusted elements.
 * <p/>
 * For Example:<br>
 * <code>Alert-Info: &lt;http://jcp.org/yeeha.wav&gt;</code>
 *
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class AlertInfoHeaderImpl extends ParametrizedHeaderBase implements AlertInfoHeader {
    private URI alertInfo;

    private final static AlertInfoHeaderParser parser = new AlertInfoHeaderParser();

    protected HeaderParser getParser() {
        return parser;
    }

    public AlertInfoHeaderImpl() {
        super(AlertInfoHeader.NAME);
    }

    AlertInfoHeaderImpl(byte[] data, int start, int end) {
        super(AlertInfoHeader.NAME, data, start, end);
    }

    public Object clone() {
        final AlertInfoHeaderImpl header = new AlertInfoHeaderImpl();
        header.cloneBase(this);
        if (parsed) {
            header.cloneParameters(this);
            header.alertInfo = this.alertInfo;
        }
        return header;
    }

    public void setAlertInfo(URI alertInfo) {
        parse();
        this.alertInfo = alertInfo;
        invalidateHeaderData();
    }

    public URI getAlertInfo() {
        parse();
        return alertInfo;
    }

    protected String getValueAsString() {
        final StringBuilder sb = new StringBuilder();
        sb.append('<').append(alertInfo.toString()).append('>');
        return sb.toString();
    }
}
/*
 * $Log$
 */